<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="${appPath}/common/common.js"></script>
<title></title>
<script type="text/javascript">

	//新增友情链接
	function addLink(){
		var form = getLinkForm();
		form.action = "${backPath}/links/goToAddLink.action";
		form.submit();
	}
	

	//删除友情链接
	function deleteLink(linkId){
		var msg = "您确认要删除本条友情链接吗?";
		if(confirm(msg)){
			var form = getLinkForm();
			document.getElementById("link.id").value = linkId;
			form.action = "${backPath}/links/deleteLink.action";			
			form.submit();
		}
	}

	//编辑友情链接
	function updateLink(linkId){
		var form = getLinkForm();
		document.getElementById("link.id").value = linkId;
		form.action = "${backPath}/links/goToEditLink.action";
		form.submit();
	}

	//获取友情链接表单对象
	function getLinkForm(){
		return document.getElementById('linkForm');
	}
		
</script>
<link href="${backPath}/images/skin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript"></script>
<style type="text/css">
<!--
body {	
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #EEF2FB;
}

.STYLE1 {font-size: 12px}
.STYLE4 {
	font-size: 12px;
	color: #1F4A65;
	font-weight: bold;
}

a:link {
	font-size: 12px;
	color: #06482a;
	text-decoration: none;

}
a:visited {
	font-size: 12px;
	color: #06482a;
	text-decoration: none;
}
a:hover {
	font-size: 12px;
	color: #FF0000;
	text-decoration: underline;
}
a:active {
	font-size: 12px;
	color: #FF0000;
	text-decoration: none;
}
.STYLE7 {font-size: 12}

-->
</style>
</head>
<body>
<form id="linkForm" action="" method="post">
<input type="hidden" name="link.id" id="link.id"/>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="${backPath}/images/mail_leftbg.gif"><img src="${backPath}/images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="${backPath}/images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">友情链接</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="${backPath}/images/mail_rightbg.gif"><img src="${backPath}/images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="${backPath}/images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" height="30"><img src="${backPath}/images/list/tab_031.gif" width="15" height="30" /></td>
        <td width="951" background="${backPath}/images/list/tab_051.gif"><img src="${backPath}/images/list/311.gif" width="16" height="16" /> <span class="STYLE4">友情链接列表</span></td>
        <td width="281" background="${backPath}/images/list/tab_051.gif"><table border="0" align="right" cellpadding="0" cellspacing="0">
            <tr>              
              <td width="200">              	
              	<table width="88%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td class="STYLE1">
                    	<div align="center">
                    		<img src="${backPath}/images/list/001.gif" width="14" height="14" />                    		
                    			&nbsp;<a href="javascript:addLink()">新增友情链接</a>                    			                                 		
                    	</div></td>                    
                  </tr>
              </table>
                	
              </td>
            </tr>
        </table></td>
        <td width="14"><img src="${backPath}/images/list/tab_071.gif" width="14" height="30" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="9" background="${backPath}/images/list/tab_121.gif">&nbsp;</td>
        <td bgcolor="#EEF2FB"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#9EAEB9">
          <tr>
          	<td width="5%" height="26" background="${backPath}/images/list/tab_141.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">编号</div></td>            
            <td width="15%" height="26" background="${backPath}/images/list/tab_141.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">链接标题</div></td>
            <td width="30%" height="26" background="${backPath}/images/list/tab_141.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">链接地址</div></td>
            <td width="10%" height="26" background="${backPath}/images/list/tab_141.gif" class="STYLE1"><div align="center" class="STYLE2">编辑</div></td>
            <td width="10%" height="26" background="${backPath}/images/list/tab_141.gif" class="STYLE1"><div align="center" class="STYLE2">删除</div></td>
          </tr>
          <s:if test="%{links.size == 0}">
          	<tr>
          		<td colspan="5" height="30" bgcolor="#FFFFFF">
          			<div align="center" class="STYLE2 STYLE1">还没有任何友情链接，请添加！</div>          		</td>
          	</tr>
          </s:if> 
          <s:else>
          		<c:forEach var="link" items="${links}" varStatus="status">
	          		<tr>	          		
	          		<c:if test="${status.index % 2 == 0}">
	          			<td class="STYLE2 STYLE1" bgcolor="#FFFFFF" align="center">${status.index+1}</td>
				  		<td class="STYLE2 STYLE1" bgcolor="#FFFFFF" align="center">${link.title}</td>
				  		<td class="STYLE2 STYLE1" bgcolor="#FFFFFF" align="center">${link.value}</td>
				  		<td height="18" bgcolor="#FFFFFF">
				  			<div align="center">
				  				<img src="${backPath}/images/list/037.gif" width="9" height="9" />
				  				<span class="STYLE1">
				  					[<a href="javascript:updateLink(${link.id})">编辑</a>]
				  				</span>
				  			</div>
				  		</td>
	           		 	<td height="18" bgcolor="#FFFFFF">
	           		 		<div align="center">
	           		 			<span class="STYLE2">
	           		 				<img src="${backPath}/images/list/010.gif" width="9" height="9" />
	           		 			</span>
	           		 			<span class="STYLE1">
	           		 			 [<a href="javascript:deleteLink(${link.id})">删除</a>]
	           		 			</span>
	           		 		</div>
	           		 	</td>
				    </c:if>
				    <c:if test="${status.index %2 == 1}">
				        <td class="STYLE2 STYLE1" bgcolor="#F1FFBF" align="center">${status.index+1}</td>
				    	<td class="STYLE2 STYLE1" bgcolor="#F1FFBF" align="center">${link.title}</td>
				  		<td class="STYLE2 STYLE1" bgcolor="#F1FFBF" align="center">${link.value}</td>				  		
				  		<td height="18" bgcolor="#F1FFBF">
				  			<div align="center"><img src="${backPath}/images/list/037.gif" width="9" height="9" />
				  				 <span class="STYLE1">
					  					[<a href="javascript:updateLink(${link.id})">编辑</a>]
					  			 </span>
					  	    </div>
					  	</td>
	           		 	<td height="18" bgcolor="#F1FFBF">
	           		 		<div align="center">
	           		 			<span class="STYLE2"><img src="${backPath}/images/list/010.gif" width="9" height="9" /></span>
	           		 			<span class="STYLE1">
	           		 				[<a href="javascript:deleteLink(${link.id})">删除</a>]
	           		 			</span>
	           		 		</div>
	           		 	</td>
	          		</c:if>	          		
          		</tr>
          	  </c:forEach>     	
          </s:else>	               
        </table>
	        <div align="center" class="STYLE2 STYLE1">
	        		<font color="red"><s:actionerror/></font>
		       		<font color="blue"><s:actionmessage/></font>
		    </div>		    
        </td>
        <td width="9" background="${backPath}/images/list/tab_161.gif">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="0">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" height="29"><img src="${backPath}/images/list/tab_201.gif" width="15" height="29" /></td>
        <td width="1000" background="${backPath}/images/list/tab_211.gif"></td>
        <td width="14"><img src="${backPath}/images/list/tab_221.gif" width="14" height="29" /></td>
      </tr>
    </table></td>
  </tr>
</table></td>
    <td background="${backPath}/images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="bottom" background="${backPath}/images/mail_leftbg.gif"><img src="${backPath}/images/buttom_left2.gif" width="17" height="17" /></td>
    <td background="${backPath}/images/buttom_bgs.gif"><img src="${backPath}/images/buttom_bgs.gif" width="17" height="17"></td>
    <td valign="bottom" background="${backPath}/images/mail_rightbg.gif"><img src="${backPath}/images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>
</form>
</body>
</html>